package com.wondream.plumelog.samples.config;

import com.wondream.plumelog.samples.interceptor.TraceIdInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Resource
    private TraceIdInterceptor traceIdInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //创建自定义的拦截器
//        TraceIdInterceptor interceptor = new TraceIdInterceptor();
        //添加拦截器
        registry.addInterceptor(traceIdInterceptor);
        		//添加需要拦截的路径
//               .addPathPatterns("/**");
    }
}
